package package02;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Description try-catch处理异常
 * @Author zzj
 * @Date 2020/7/15 16:07
 */
public class ExceptionDemo04 {
    public static void main(String[] args) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String s = "2019-01-01 12:21:11";

        // try-catch处理异常
        Date date = null;
        try {
            date = sdf.parse(s);
            System.out.println("出现异常后，之后的代码不再执行，而是转到异常处理");
        } catch (ParseException e) {
            e.printStackTrace();
        }

        System.out.println(date);
    }
}
